<?xml version="1.0" encoding="windows-1250"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xml:space="default">
  <xsl:output method="xml" encoding="windows-1250" indent="yes"/>

  <xsl:template match="/">
    <ModelDepsPaths>
      <xsl:apply-templates select="Concepts/Concept[@iscovereroot='yes']"/>
    </ModelDepsPaths>
  </xsl:template>

  <xsl:template match="Concept">
    <xsl:param name="path"/>
    <xsl:param name="cov"><xsl:value-of select="@name"/></xsl:param>
    <xsl:variable name="newpath">
      <xsl:choose>
        <xsl:when test="$path"><xsl:value-of select="$path"/><xsl:value-of select="@coll"/>/<xsl:value-of select="@name"/></xsl:when>
        <xsl:otherwise><xsl:value-of select="@name"/></xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:for-each select="CProperties/CProperty[@ref and @ref!='' and (not(@refdep) or @refdep='1')]">
      <DepPath cov="{$cov}" path="{$newpath}" ref="{substring-before(@ref,'/')}" prop="{@name}"/>  
    </xsl:for-each>
    <xsl:for-each select="CAssociations/CAssociation[@type='recursive']">
      <xsl:variable name="c" select="/Concepts/Concept[@id_concept=current()/@id_cchild]"/>
      <xsl:for-each select="$c/CProperties/CProperty[@ref and @ref!='' and (not(@refdep) or @refdep='1')]">
        <DepPath cov="{$cov}" path="{substring-after($newpath,'/')}/{$c/@coll}/{$c/@name}" ref="{substring-before(@ref,'/')}" prop="{@name}" recursive="yes"/>  
      </xsl:for-each>
    </xsl:for-each>
    <xsl:for-each select="CAssociations/CAssociation[@type='composite']">
      <xsl:apply-templates select="/Concepts/Concept[@id_concept=current()/@id_cchild]">
        <xsl:with-param name="path"><xsl:value-of select="$newpath"/>/</xsl:with-param>
        <xsl:with-param name="cov"><xsl:value-of select="$cov"/></xsl:with-param>
      </xsl:apply-templates>
    </xsl:for-each>
  </xsl:template>


</xsl:stylesheet>